<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns the color count associated with this color</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="imagickpixel.getcolorasstring.html">« ImagickPixel::getColorAsString</a></li>
      <li style="float: right;"><a href="imagickpixel.getcolorquantum.html">ImagickPixel::getColorQuantum »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.imagickpixel.html">ImagickPixel</a></li>
    <li>Returns the color count associated with this color</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="imagickpixel.getcolorcount" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ImagickPixel::getColorCount</h1>
  <p class="verinfo">(PECL imagick 2, PECL imagick 3)</p><p class="refpurpose"><span class="refname">ImagickPixel::getColorCount</span> &mdash; <span class="dc-title">Returns the color count associated with this color</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-imagickpixel.getcolorcount-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ImagickPixel::getColorCount</strong></span>(): <span class="type">int</span></div>

  <p class="para rdfs-comment">
   Returns the color count associated with this color.
  </p>
  <p class="para">The color count is the number of pixels in the image that have the same color as this ImagickPixel.
  </p>
  <p class="para">
   ImagickPixel::getColorCount appears to only work for ImagickPixel objects created through Imagick::getImageHistogram()
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-imagickpixel.getcolorcount-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-imagickpixel.getcolorcount-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the color count as an integer on success, throws
  ImagickPixelException on failure.
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-imagickpixel.getcolorcount-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2969">
      <p><strong>示例 #1 ImagickPixel <span class="function"><strong>getColorCount()</strong></span></strong></p>
      <div class="example-contents">
      <div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;$imagick&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;\</span><span style="color: #0000BB">Imagick</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">newPseudoImage</span><span style="color: #007700">(</span><span style="color: #0000BB">640</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">480</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"magick:logo"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$histogramElements&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getImageHistogram</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$lastColor&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">array_pop</span><span style="color: #007700">(</span><span style="color: #0000BB">$histogramElements</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Last&nbsp;pixel&nbsp;color&nbsp;count&nbsp;is:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">$lastColor</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getColorCount</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
      </div>

        <div class="example-contents"><p>
The output for this will be similar to:
    </p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Last pixel color count is: 256244
</pre></div>
    </div>
    </div>
  </p>
</div>


</div></div></div></body></html>